import {message} from 'antd';
import history from 'history/browser';
import menuDatas from '@/assets/_defaultProps';

const loginState = {
    loginStats: false,

};
const menuDataState = {
    menuData: [],
};

export function loginReducer(state = loginState, action: any) {
    switch (action.type) {
        case 'LOGIN_SUCCESS':
            message.success('登录成功');
            history.replace('/', {replace: true});
            history.go(0);
            return {...state, loginStats: true};
        default:
            return state;
    }
}

export function menuDataReducer(state = menuDataState, action: any) {
    switch (action.type) {
        case "SET_MENU_DATA":
            return {...state, menuData: menuDatas};
        default:
            return state;
    }
}


